<?php
# !!!!!!!!!! DON'T MAKE ANY CHANGE IF YOU DON'T KNOW WHAT YOU'RE DOING !!!!!!!!!!
// --------------------------------------------------------------------------------------------------------------
// File Name              :	homepage.php
// Last Modification Time	:	2008-02-01 24:00
// Last Modified by       :	turker (turker.biz@gmail.com)
// list of modifications	:
//
//	- 2008-02-01 turker
//		* 24:00 file created.
//
// --------------------------------------------------------------------------------------------------------------
if (eregi("homepage.php",$_SERVER['PHP_SELF'])) {
	header ("Location:../index.php");
	exit;
}
?>
<!--div:icerik -->
    <div id="icerik">
<?php

$items=homeItems();
// id, item, summary, info, name, home, new, lang, show_price, xml_code, image, date, brand_id, active, order, stock,
// price, p_info, campaign, campaign_price, p_active, ex_name, exchange, e_active
if ($items==false) echo $_LANG['homepage']['error1'];
else {
  $k=0;
  echo '<table cellpadding="5" cellspacing="5" width="100%" id="itemslist">';
  echo '<tr>';
  for ($i=0;$i<count($items);$i++){
    $item=$items[$i];
    $item_id=$item['id']; #*
    $title=$prep->html($item['item']); # urun adı*
    $summary=$prep->html($item['summary']); # urun özeti*
    $name=$item['name']; # urun permalink*
    $new=$item['new']; # yeni urun*
    $show_price=$item['show_price']; # fiyat goster*
    $item_active=$item['active']; # ürün aktif*
    $image=$item['image']; # urun foto*
    $price=$item['price']; # fiyat*
    $info=$prep->html($item['p_info']); # fiyat açıklaması
    $campaign=$item['campaign']; # kampanya*
    $campaign_price=$item['campaign_price']; # kampanya fiyatı*
    $item_price_active=$item['p_active']; # fiyat aktif *
    $ename=$prep->html($item['ex_name']); # kur adı*
    $exchange=$item['exchange']; # kur *
    $e_active=$item['e_active']; # kur aktif *

    // prepare item details
    $price="$price $ename +KDV";
    if (empty($image)||!file_exists('img/'.$image)) $image='template/img/noimg.png';
    else $image='img/'.$image;
    if ($new) $new='<img src="template/img/yeni.gif" />'; else $new='';
    if ($campaign_price>0&&$campaign) {
      $campaign='<img src="template/img/kampanya.gif" /><br />';
      $price="<s>$price</s> $campaign_price $ename +KDV";
    }
    else $campaign='';
    if (!$show_price) $price='';
    $item_link='<a href="index.php?page=item&id='.$item_id.'">'.$title.'</a>';
    if ($SITE_SEO) $item_link='<a href="'.$SITE_URL.'/item/'.$name.'">'.$title.'</a>';
    // -------------

    if (isAdmin()) {
      $show_price=1;
    }
    elseif (isLogged()) {
      if(!empty($item['price'])) {
        if ($show_price) {
          if ($item_price_active!='1'||$e_active!='1') {
            $price=$_LANG['homepage']['oostock'];
            $info='';
            $campaign='';
          }
        }
        else $price=$_LANG['homepage']['aprice'];
      }
      else $item_active=0;
    }
    else {
      if(!empty($item['price'])) {
        if ($SHOW_ITEM_PRICE==0) {
          $price='';
          $campaign='';
        }
        else {
          if ($show_price) {
            if ($item_price_active!='1'||$e_active!='1') {
              $price=$_LANG['homepage']['oostock'];
              $info='';
              $campaign='';
            }
          }
          else $price=$_LANG['homepage']['aprice'];
        }
      }
      else $item_active=0;
    }
    // -------------
    if (isAdmin()||$item_active=='1') {
      if (isAdmin()&&$item_active=='1') $item_active='<img src="template/img/active.gif" title="Ürün Aktif" />';
      elseif (isAdmin()&&$item_active=='0') $item_active='<img src="template/img/notactive.gif" title="Ürün Aktif Değil" />';
      else $item_active='';

      $price=trim($price);
      if ($price=='+KDV') $price=$_LANG['homepage']['nhprice'];

      echo <<<html
      <td id="item-$id" class="item" width="50%">$new $item_link $item_active<br />
      <img src="$image" align="left" class="item-img" title="$title" />$summary<br /><br />
      $info<br />$campaign $price
      </td>
html;
      if ($k%$ITEM_DISPLAY_COLUMN!=0) echo '</tr><tr>';
      $k++;
    }
  }
  echo '</tr></table>';
}
?>
    </div>
<!--//div:icerik -->